package com.itheima.test;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.junit.Test;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

public class baiduMApTEST {



    @Test
    public void test() throws Exception{
        RestTemplate restTemplate = new RestTemplate();
        ResponseEntity<String> forEntity = restTemplate.getForEntity("https://api.map.baidu.com/reverse_geocoding/v3/?ak=3jSM556yifDs7D2VcriyKewBX0by4tG7&output=json&coordtype=wgs84ll&location=31.225696563611,121.49884033194", String.class);
        String body = forEntity.getBody();
        JSONObject jsonObject = JSON.parseObject(body);
        JSONObject result = (JSONObject) jsonObject.get("result");
        Object formatted_address = result.get("formatted_address");
        System.out.println(formatted_address);

    }
}

